package org.nowcoder.huawei.other;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * HJ33: 整数与IP地址间的转换
 */
public class HJ33 {
    public static void main(String[] args) throws Exception {
        hj33();
    }

    public static void hj33() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String ip = br.readLine();
        StringBuilder builder = new StringBuilder();
        for (String s : ip.split("\\.")) {
            String bs = Integer.toBinaryString(Integer.parseInt(s));
            builder.append(bs.length() < 8 ? "00000000".substring(0, 8 - bs.length()) + bs : bs);
        }
        System.out.println(Long.parseLong(builder.toString(), 2));


        long l = Long.parseLong(br.readLine());
        String bs = Long.toBinaryString(l);
        bs = bs.length() < 32 ? "0000000000000000000000000000000000000000000000000000000000000000".substring(0, 32 - bs.length()) + bs : bs;
        int i = Integer.parseInt(bs.substring(0, 8), 2);
        int j = Integer.parseInt(bs.substring(8, 16), 2);
        int k = Integer.parseInt(bs.substring(16, 24), 2);
        int m = Integer.parseInt(bs.substring(24, 32), 2);
        System.out.println(i + "." + j + "." + k + "." + m);
    }
}
